package cn.java.Concurrency;

import java.util.concurrent.*;

/**
 * @author 小石潭记
 * @date 2021/12/19 10:09
 * @Description: ${todo}
 */
public class Run {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable myCallable = new MyCallable(100);
        ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 3,
                5L, TimeUnit.SECONDS,
                new LinkedBlockingQueue<>());
        Future<String> future = executor.submit(myCallable);
//        System.out.println("main A" + System.currentTimeMillis());
//        System.out.println(future.get());
//        System.out.println("main B" + System.currentTimeMillis());

        System.out.println(future.cancel(true) + " " + future.isCancelled());
    }
}
